<?php
/**
 * CreateTime: 2023/11/15 10:17
 * User:LinQ
 */
namespace Database\Seeders\Database;

use App\Func\User\UserFunc;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Symfony\Component\Uid\UuidV4;

class UserSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $isExists = DB::table('users')->select('user_id')->where('account','admin')->first();
        if(!$isExists){
            $puPvKey = rsa_pu_pv_key();
            DB::table('users')->insert([
                'name' => 'admin',
                'com_id' => 1,
                'account' => 'admin',
                'email' => Str::random(10).'@gmail.com',
                'phone' => Str::random(11),
                'password' => (new UserFunc())->getHashPassByUser('admin'),
                'union_id' => UuidV4::v6()->toRfc4122(),
                'enable_status' => 1,
                'status' => 1,
                'pu_key' => $puPvKey['pu_key'],
                'pv_key' => $puPvKey['pv_key'],
                'created_at' => date("Y-m-d h:i:s"),
                'updated_at' => date("Y-m-d h:i:s"),
            ]);
        }

    }
}
